import redis

# 连接Redis
conn = redis.Redis(host="192.168.5.132")

# 1、添加数据
# conn.hset("hot_goods", "name", "小米 14")
# conn.hset("hot_goods", "price", 2999)
# conn.hset("hot_goods", "desc", "very goods")
# 一次性添加多个键值对

conn.hmset("famous_people", {"name": "friendship", "sex": "man", "address": "china"})

print(conn.hgetall("famous_people"))
# 获取数据
# name = conn.hget("hot_goods", "name")  # 单个字段的数据
# print(name.decode("utf-8"))


# hot_goods = conn.hgetall("hot_goods")  # 热点商品 所有信息
# print(hot_goods)


# 修改数据 就是重新设置

# 删除数据
# conn.hdel("hot_goods", "name")  # 删除指定字段
#
# print(conn.hget("hot_goods", "name"))

